//注册
let express = require('express');
let path = require('path');
let mysql = require('mysql');
//引入自定义模块
let user = require('../model/user');

var router = express.Router();

router.post('/',function(req,res) {
    let name = req.body.username;
    let pw = req.body.password;
    //查看用户名是否存在
    user.searchID(name,function (len){
        if(len === 1){
            res.send({regStatus:1});
        }
        else{
            user.searchMaxUserID(function (userID){
                user.add(userID+1,name,pw);
            })
            res.send({regStatus:0});
        }
    })
})

module.exports = router;
